<?php    
session_start();        
include('system/connect.php');   
$my_id = $_SESSION['my_id'];
$sql = "SELECT
        sf_guard_user.id,
        sf_guard_user.account
        FROM
        sf_guard_user
        WHERE
        sf_guard_user.id =  '$my_id'
        limit 0,1";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
    $my = $row;
} 
if ($my['account'] <= 0) {
    echo('e');
    exit();
}

$op_id = (int)$_GET['uid'];
$room_id = (int)$_GET['rid'];
$time = time();                                             
$sql = "update chat2_room set time=$time where id = '$room_id'";
mysql_query($sql);   
$sql = "select * from chat2_chanels where user_id = '$op_id' limit 0,1";
$result = mysql_query($sql);
while ($row = mysql_fetch_assoc($result)) {
    $chanels = $row;
} 
if (!empty($chanels)) {
    $sql = "update chat2_room set with_video='".$chanels['user_src']."' where id = '$room_id'";
    $res = mysql_query($sql,$sock);     
      
    $sql = "update sf_guard_user set account=(account-0.05) where id = '$my_id'";
    mysql_query($sql);   
    echo($chanels['id']);
} else {
    echo(0);
}

?>